%电机参数
Rs = 0.02;
Ls = 74e-6;

%期望的系统带宽
W=200*2*pi;

%低通滤波
Wlpf = 24100;
G_lpf = tf(Wlpf, [1 Wlpf]);

%pi控制器参数
Kp = W * Ls;
Ki = W * Rs;

L_scale = 1/2;
R_scale = 2;
%被控对象的模型
G_plant = tf(1/(Ls * L_scale), [1 (Rs * R_scale)/(Ls * L_scale)]);

%pi的传递函数
G_pi = Kp * tf([1 Ki/Kp], [1 0]);

%开环传递函数
G_Open = G_pi * G_plant;

%闭环传递函数
G_Close = G_Open/(1 + G_Open * G_lpf);

%bode图
figure(1);
bodeplot(G_Close, '-r');
grid on;
%输入阶跃信号的输出信号
figure(2);
step(G_Close, 0.1);
grid on;

bandwidth(G_Close)/2/pi
